#pragma once

#include "mccommonapi.h"

#include <string>
#include <xercesc/dom/DOM.hpp>

namespace MCCommon
{

class XMLElementIterator;
class XMLTextIterator;

class MCAPI XMLElement
{
public:
    /**
     * Constructor.
     * 
     */
    XMLElement
    ( 
        xercesc::DOMElement* pDomElement
    );

    /**
     * Destructor.
     * 
     */
    virtual ~XMLElement();
    
    /**
     * Copy constructor.
     * 
     */
    XMLElement
    (
        const XMLElement& element
    );

    /**
     * Assign operator.
     * 
     */
    XMLElement& operator = 
    (
        const XMLElement& element
    );

    /**
     * Get name.
     * 
     */
    bool GetName
    (
        std::string& name
    );
    
    /**
     * Is having attribute.
     * 
     */
    bool IsHaveAttribute
    (
        const std::string &name
    );

    /**
     * Add attribute.
     * 
     */
    bool AddAttribute
    (
        const std::string& name, 
        const std::string& value
    );

    /**
     * Get attribute.
     * 
     */  
    bool GetAttribute
    (
        const std::string& name, 
        std::string& value
    );  
      
    /**
     * Add element.
     * 
     */
    XMLElement AddElement
    (
        const std::string& name
    );
    XMLElement AddElement
    (
        const std::string& name, 
        const std::string& text
    );
    
    /**
     * Get element.
     * 
     */
    XMLElement GetElement
    (
        const std::string& name
    );

    /**
     * Get element iterator.
     * 
     */
    XMLElementIterator GetElementIterator
    (
        const std::string& name
    );
    
    /**
     * Set text.
     * 
     */    
    bool SetText
    (
        const std::string& text
    );
    
    /**
     * Get text iterator.
     * 
     */ 
    XMLTextIterator GetTextIterator
    (
        const std::string& name
    );

    /**
     * To string.
     * 
     */
    bool ToString(std::string& docString); 

protected:
    /**
     * Default constructor.
     * 
     */
    XMLElement();

protected:
    
    // Dom element.
    xercesc::DOMElement* fDomElement;
};

}// end of namespace MCXML_NAMESPACE